const { reject } = require("lodash")

new Promise((resolve, reject) => {
    resolve(1)
}).then((value)=>{
    // x是普通值
    console.log("promise then " , value)
    return 2
}).then((value)=>{
    // x是函数
    console.log("promise then ", value)
    return function(){
        console.log(3)
    }
}).then((value)=>{
    console.log("promise then ", value)
    // x是Promise
    let p = new Promise((resolve, reject) =>{
        resolve(11)
    })
    return p
}).then((value) =>{
    console.log("promise then ", value)
    return 22
}).finally(()=>{
    console.log("promise finally")
}).then((value)=>{
    console.log(value)
})

Promise.resolve(Promise.resolve(123)).then((value) => {
    console.log(value)
})

Promise.resolve(Promise.reject(122)).then((value)=>{
    console.log("Promise then", value)
}).catch((reason) => {
    console.log("Promise catch", reason)
})

Promise.resolve().then((value)=>{
    console.log("Promise then", value)
}).catch((reason) => {
    console.log("Promise catch", reason)
})

Promise.reject(12).catch((reason) => {
    console.log("Promise catch before finally" , reason)
}).finally(()=>{
    console.log("Promise finally")
}).catch((reason) => {
    console.log("Promise catch after finally" , reason)
})